package com.hh.test.util;

import java.io.File;
import java.io.FilenameFilter;

import org.apache.commons.io.filefilter.NameFileFilter;
import org.apache.commons.io.filefilter.PrefixFileFilter;

public class RenameDir {

	public static void main(String[] args) {
		new RenameDir("C:\\Users\\admin\\Desktop\\2", "微信图片").rename();
	}

	private String dir;
	private String filter;

	public void rename() {
		FilenameFilter filters = new PrefixFileFilter(getFilter());
		File[] files = new File(getDir()).listFiles(filters);
		for (File f : files) {
			System.out.println(f.getName());
			f.renameTo(new File(f.getName().replace("微信图片_2018052416591", "")));
		}
	}

	public RenameDir(String dir, String filter) {
		this.dir = dir;
		this.filter = filter;
	}

	public String getFilter() {
		return filter;
	}

	public void setFilter(String filter) {
		this.filter = filter;
	}

	public String getDir() {
		return dir;
	}

	public void setDir(String dir) {
		this.dir = dir;
	}

}
